package br.com.comdoc.telas;

import br.com.comdoc.fachada.FachadaProduto;
import java.awt.Color;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.sql.SQLException;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileNameExtensionFilter;

public class TelaSalvarProduto extends javax.swing.JDialog {

    public TelaSalvarProduto(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        this.rootPane.setDefaultButton(salvar);
        this.rootPane.getContentPane().setBackground(Color.white);
    }
    private String url = "C:\\Cubesoft\\Comdoc\\Imagens";
    private JFileChooser fileChooser;
    private FileNameExtensionFilter filter;
    private String img;

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        buttonGroup3 = new javax.swing.ButtonGroup();
        status = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        imagen = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        salvar = new javax.swing.JButton();
        cancelar = new javax.swing.JButton();
        modelo = new javax.swing.JTextField();
        marca = new javax.swing.JTextField();
        velocidade = new javax.swing.JTextField();
        tipo = new javax.swing.JTextField();
        resolucao = new javax.swing.JTextField();
        ciclo = new javax.swing.JTextField();
        memoria = new javax.swing.JTextField();
        processador = new javax.swing.JTextField();
        conectividade = new javax.swing.JTextField();
        papel = new javax.swing.JTextField();
        valorMaximoVenda = new javax.swing.JTextField();
        rendimento = new javax.swing.JTextField();
        valorMaximoLocacao = new javax.swing.JTextField();
        valorMinVenda = new javax.swing.JTextField();
        valorMinLocacao = new javax.swing.JTextField();
        jCheckBox1 = new javax.swing.JCheckBox();
        duplex = new javax.swing.JCheckBox();
        fax = new javax.swing.JCheckBox();
        digitalizacao = new javax.swing.JCheckBox();
        ajuda = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Adicionar Produto");
        setUndecorated(true);
        setPreferredSize(new java.awt.Dimension(800, 500));
        setResizable(false);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        status.setBackground(new java.awt.Color(255, 255, 255));
        status.setBorder(javax.swing.BorderFactory.createEtchedBorder(new java.awt.Color(255, 204, 0), new java.awt.Color(255, 204, 0)));
        status.setOpaque(false);
        status.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));
        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder(null, new java.awt.Color(255, 204, 0)));
        jPanel2.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jPanel2.setPreferredSize(new java.awt.Dimension(100, 170));
        jPanel2.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        imagen.setFont(new java.awt.Font("Microsoft JhengHei", 0, 14)); // NOI18N
        imagen.setForeground(new java.awt.Color(102, 102, 102));
        imagen.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        imagen.setText("Imagem");
        imagen.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                imagenMouseClicked(evt);
            }
        });
        jPanel2.add(imagen, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 280, 150));

        status.add(jPanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 60, 300, -1));

        jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/comdoc/imagens/Linha_Rodape_Adicionar_Produto.png"))); // NOI18N
        jLabel3.setText("jLabel3");
        status.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 450, 780, -1));

        jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/comdoc/imagens/Simbolo_Cubesoft.png"))); // NOI18N
        status.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(710, 470, -1, -1));

        salvar.setBackground(new java.awt.Color(255, 255, 255));
        salvar.setFont(new java.awt.Font("Microsoft JhengHei", 1, 14)); // NOI18N
        salvar.setText("Salvar");
        salvar.setBorder(javax.swing.BorderFactory.createEtchedBorder(null, new java.awt.Color(255, 204, 0)));
        salvar.setContentAreaFilled(false);
        salvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                salvarActionPerformed(evt);
            }
        });
        status.add(salvar, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 470, 70, -1));

        cancelar.setBackground(new java.awt.Color(255, 255, 255));
        cancelar.setFont(new java.awt.Font("Microsoft JhengHei", 1, 14)); // NOI18N
        cancelar.setText("Cancelar");
        cancelar.setBorder(javax.swing.BorderFactory.createEtchedBorder(null, new java.awt.Color(255, 204, 0)));
        cancelar.setContentAreaFilled(false);
        status.add(cancelar, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 470, 80, -1));

        modelo.setFont(new java.awt.Font("Microsoft JhengHei", 0, 12)); // NOI18N
        modelo.setForeground(new java.awt.Color(204, 204, 204));
        modelo.setText("Modelo");
        modelo.setBorder(javax.swing.BorderFactory.createEtchedBorder(null, new java.awt.Color(255, 204, 0)));
        modelo.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                modeloFocusLost(evt);
            }
            public void focusGained(java.awt.event.FocusEvent evt) {
                modeloFocusGained(evt);
            }
        });
        modelo.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                modeloKeyPressed(evt);
            }
        });
        status.add(modelo, new org.netbeans.lib.awtextra.AbsoluteConstraints(580, 60, 210, -1));

        marca.setFont(new java.awt.Font("Microsoft JhengHei", 0, 12)); // NOI18N
        marca.setForeground(new java.awt.Color(204, 204, 204));
        marca.setText("Marca");
        marca.setBorder(javax.swing.BorderFactory.createEtchedBorder(null, new java.awt.Color(255, 204, 0)));
        marca.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                marcaFocusLost(evt);
            }
            public void focusGained(java.awt.event.FocusEvent evt) {
                marcaFocusGained(evt);
            }
        });
        marca.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                marcaKeyPressed(evt);
            }
        });
        status.add(marca, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 60, 210, -1));

        velocidade.setFont(new java.awt.Font("Microsoft JhengHei", 0, 12)); // NOI18N
        velocidade.setForeground(new java.awt.Color(204, 204, 204));
        velocidade.setText("Velocidade");
        velocidade.setBorder(javax.swing.BorderFactory.createEtchedBorder(null, new java.awt.Color(255, 204, 0)));
        velocidade.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                velocidadeFocusLost(evt);
            }
            public void focusGained(java.awt.event.FocusEvent evt) {
                velocidadeFocusGained(evt);
            }
        });
        velocidade.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                velocidadeKeyPressed(evt);
            }
        });
        status.add(velocidade, new org.netbeans.lib.awtextra.AbsoluteConstraints(580, 90, 210, -1));

        tipo.setFont(new java.awt.Font("Microsoft JhengHei", 0, 12)); // NOI18N
        tipo.setForeground(new java.awt.Color(204, 204, 204));
        tipo.setText("Tipo");
        tipo.setBorder(javax.swing.BorderFactory.createEtchedBorder(null, new java.awt.Color(255, 204, 0)));
        tipo.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                tipoFocusLost(evt);
            }
            public void focusGained(java.awt.event.FocusEvent evt) {
                tipoFocusGained(evt);
            }
        });
        tipo.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tipoKeyPressed(evt);
            }
        });
        status.add(tipo, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 90, 210, -1));

        resolucao.setFont(new java.awt.Font("Microsoft JhengHei", 0, 12)); // NOI18N
        resolucao.setForeground(new java.awt.Color(204, 204, 204));
        resolucao.setText("Resolução");
        resolucao.setBorder(javax.swing.BorderFactory.createEtchedBorder(null, new java.awt.Color(255, 204, 0)));
        resolucao.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                resolucaoFocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                resolucaoFocusLost(evt);
            }
        });
        resolucao.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                resolucaoKeyPressed(evt);
            }
        });
        status.add(resolucao, new org.netbeans.lib.awtextra.AbsoluteConstraints(580, 120, 210, -1));

        ciclo.setFont(new java.awt.Font("Microsoft JhengHei", 0, 12)); // NOI18N
        ciclo.setForeground(new java.awt.Color(204, 204, 204));
        ciclo.setText("Ciclo mensal");
        ciclo.setBorder(javax.swing.BorderFactory.createEtchedBorder(null, new java.awt.Color(255, 204, 0)));
        ciclo.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                cicloFocusLost(evt);
            }
            public void focusGained(java.awt.event.FocusEvent evt) {
                cicloFocusGained(evt);
            }
        });
        ciclo.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                cicloKeyPressed(evt);
            }
        });
        status.add(ciclo, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 120, 210, -1));

        memoria.setFont(new java.awt.Font("Microsoft JhengHei", 0, 12)); // NOI18N
        memoria.setForeground(new java.awt.Color(204, 204, 204));
        memoria.setText("Memória");
        memoria.setBorder(javax.swing.BorderFactory.createEtchedBorder(null, new java.awt.Color(255, 204, 0)));
        memoria.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                memoriaFocusLost(evt);
            }
            public void focusGained(java.awt.event.FocusEvent evt) {
                memoriaFocusGained(evt);
            }
        });
        memoria.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                memoriaKeyPressed(evt);
            }
        });
        status.add(memoria, new org.netbeans.lib.awtextra.AbsoluteConstraints(580, 150, 210, -1));

        processador.setFont(new java.awt.Font("Microsoft JhengHei", 0, 12)); // NOI18N
        processador.setForeground(new java.awt.Color(204, 204, 204));
        processador.setText("Processador");
        processador.setBorder(javax.swing.BorderFactory.createEtchedBorder(null, new java.awt.Color(255, 204, 0)));
        processador.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                processadorFocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                processadorFocusLost(evt);
            }
        });
        processador.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                processadorKeyPressed(evt);
            }
        });
        status.add(processador, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 150, 210, -1));

        conectividade.setFont(new java.awt.Font("Microsoft JhengHei", 0, 12)); // NOI18N
        conectividade.setForeground(new java.awt.Color(204, 204, 204));
        conectividade.setText("Conectividade");
        conectividade.setBorder(javax.swing.BorderFactory.createEtchedBorder(null, new java.awt.Color(255, 204, 0)));
        conectividade.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                conectividadeFocusLost(evt);
            }
            public void focusGained(java.awt.event.FocusEvent evt) {
                conectividadeFocusGained(evt);
            }
        });
        conectividade.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                conectividadeKeyPressed(evt);
            }
        });
        status.add(conectividade, new org.netbeans.lib.awtextra.AbsoluteConstraints(580, 180, 210, -1));

        papel.setFont(new java.awt.Font("Microsoft JhengHei", 0, 12)); // NOI18N
        papel.setForeground(new java.awt.Color(204, 204, 204));
        papel.setText("Capacidade de papel");
        papel.setBorder(javax.swing.BorderFactory.createEtchedBorder(null, new java.awt.Color(255, 204, 0)));
        papel.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                papelFocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                papelFocusLost(evt);
            }
        });
        papel.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                papelKeyPressed(evt);
            }
        });
        status.add(papel, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 180, 210, -1));

        valorMaximoVenda.setFont(new java.awt.Font("Microsoft JhengHei", 0, 12)); // NOI18N
        valorMaximoVenda.setForeground(new java.awt.Color(204, 204, 204));
        valorMaximoVenda.setText("Valor máximo (venda)");
        valorMaximoVenda.setBorder(javax.swing.BorderFactory.createEtchedBorder(null, new java.awt.Color(255, 204, 0)));
        valorMaximoVenda.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                valorMaximoVendaFocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                valorMaximoVendaFocusLost(evt);
            }
        });
        valorMaximoVenda.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                valorMaximoVendaKeyPressed(evt);
            }
        });
        status.add(valorMaximoVenda, new org.netbeans.lib.awtextra.AbsoluteConstraints(580, 210, 210, -1));

        rendimento.setFont(new java.awt.Font("Microsoft JhengHei", 0, 12)); // NOI18N
        rendimento.setForeground(new java.awt.Color(204, 204, 204));
        rendimento.setText("Rendimento do toner");
        rendimento.setBorder(javax.swing.BorderFactory.createEtchedBorder(null, new java.awt.Color(255, 204, 0)));
        rendimento.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                rendimentoFocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                rendimentoFocusLost(evt);
            }
        });
        rendimento.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                rendimentoKeyPressed(evt);
            }
        });
        status.add(rendimento, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 210, 210, -1));

        valorMaximoLocacao.setFont(new java.awt.Font("Microsoft JhengHei", 0, 12)); // NOI18N
        valorMaximoLocacao.setForeground(new java.awt.Color(204, 204, 204));
        valorMaximoLocacao.setText("Valor máximo (locação)");
        valorMaximoLocacao.setBorder(javax.swing.BorderFactory.createEtchedBorder(null, new java.awt.Color(255, 204, 0)));
        valorMaximoLocacao.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                valorMaximoLocacaoFocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                valorMaximoLocacaoFocusLost(evt);
            }
        });
        valorMaximoLocacao.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                valorMaximoLocacaoKeyPressed(evt);
            }
        });
        status.add(valorMaximoLocacao, new org.netbeans.lib.awtextra.AbsoluteConstraints(580, 240, 210, -1));

        valorMinVenda.setFont(new java.awt.Font("Microsoft JhengHei", 0, 12)); // NOI18N
        valorMinVenda.setForeground(new java.awt.Color(204, 204, 204));
        valorMinVenda.setText("Valor mínimo (venda)");
        valorMinVenda.setBorder(javax.swing.BorderFactory.createEtchedBorder(null, new java.awt.Color(255, 204, 0)));
        valorMinVenda.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                valorMinVendaFocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                valorMinVendaFocusLost(evt);
            }
        });
        valorMinVenda.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                valorMinVendaKeyPressed(evt);
            }
        });
        status.add(valorMinVenda, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 240, 210, -1));

        valorMinLocacao.setFont(new java.awt.Font("Microsoft JhengHei", 0, 12)); // NOI18N
        valorMinLocacao.setForeground(new java.awt.Color(204, 204, 204));
        valorMinLocacao.setText("Valor mínimo (locação)");
        valorMinLocacao.setBorder(javax.swing.BorderFactory.createEtchedBorder(null, new java.awt.Color(255, 204, 0)));
        valorMinLocacao.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                valorMinLocacaoFocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                valorMinLocacaoFocusLost(evt);
            }
        });
        valorMinLocacao.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                valorMinLocacaoKeyPressed(evt);
            }
        });
        status.add(valorMinLocacao, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 270, 210, -1));

        jCheckBox1.setBackground(new java.awt.Color(255, 255, 255));
        jCheckBox1.setFont(new java.awt.Font("Microsoft JhengHei", 0, 12)); // NOI18N
        jCheckBox1.setForeground(new java.awt.Color(102, 102, 102));
        jCheckBox1.setText("Produto inativo");
        jCheckBox1.setBorder(javax.swing.BorderFactory.createEtchedBorder(null, new java.awt.Color(255, 204, 0)));
        jCheckBox1.setBorderPainted(true);
        status.add(jCheckBox1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 330, 300, -1));

        duplex.setBackground(new java.awt.Color(255, 255, 255));
        duplex.setFont(new java.awt.Font("Microsoft JhengHei", 0, 12)); // NOI18N
        duplex.setForeground(new java.awt.Color(102, 102, 102));
        duplex.setText("Duplex");
        duplex.setBorder(javax.swing.BorderFactory.createEtchedBorder(null, new java.awt.Color(255, 204, 0)));
        duplex.setBorderPainted(true);
        status.add(duplex, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 240, 300, -1));

        fax.setBackground(new java.awt.Color(255, 255, 255));
        fax.setFont(new java.awt.Font("Microsoft JhengHei", 0, 12)); // NOI18N
        fax.setForeground(new java.awt.Color(102, 102, 102));
        fax.setText("FAX");
        fax.setBorder(javax.swing.BorderFactory.createEtchedBorder(null, new java.awt.Color(255, 204, 0)));
        fax.setBorderPainted(true);
        status.add(fax, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 270, 300, -1));

        digitalizacao.setBackground(new java.awt.Color(255, 255, 255));
        digitalizacao.setFont(new java.awt.Font("Microsoft JhengHei", 0, 12)); // NOI18N
        digitalizacao.setForeground(new java.awt.Color(102, 102, 102));
        digitalizacao.setText("Digitalização");
        digitalizacao.setBorder(javax.swing.BorderFactory.createEtchedBorder(null, new java.awt.Color(255, 204, 0)));
        digitalizacao.setBorderPainted(true);
        status.add(digitalizacao, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 300, 300, -1));

        ajuda.setFont(new java.awt.Font("Microsoft JhengHei", 2, 12)); // NOI18N
        ajuda.setForeground(new java.awt.Color(102, 102, 102));
        ajuda.setText("Ajuda.");
        status.add(ajuda, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 430, 780, -1));

        getContentPane().add(status, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 800, 500));

        jLabel2.setFont(new java.awt.Font("Microsoft JhengHei", 1, 24)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel2.setText("X");
        jLabel2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabel2MouseClicked(evt);
            }
        });
        getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(754, 0, 50, 50));

        jLabel1.setBackground(new java.awt.Color(102, 102, 102));
        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/comdoc/imagens/Cabecalho_Adicionar_Produto.png"))); // NOI18N
        getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 800, 50));

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void jLabel2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel2MouseClicked
        this.dispose();
    }//GEN-LAST:event_jLabel2MouseClicked

    private void imagenMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_imagenMouseClicked
        fileChooser = new JFileChooser(url);
        fileChooser.setDialogTitle("Adicionar imagem ao produto");
        filter = new FileNameExtensionFilter("JPG & GIF Images", "jpg", "gif");
        fileChooser.setFileFilter(filter);
        fileChooser.setAcceptAllFileFilterUsed(false);
        fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
        if (fileChooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) {
        } else if (true) {
            imagen.setText(null);
            imagen.setIcon(new ImageIcon(fileChooser.getSelectedFile().getPath()));
            img = fileChooser.getSelectedFile().getAbsolutePath();
            imagen.updateUI();
        }
    }//GEN-LAST:event_imagenMouseClicked

    private void marcaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_marcaKeyPressed
        if (marca.getText().trim().equals("Marca")) {
            marca.setText(null);
            marca.setForeground(new Color(102, 102, 102));
        }
    }//GEN-LAST:event_marcaKeyPressed

    private void marcaFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_marcaFocusLost
        this.ajuda.setText("Ajuda.");
        if (marca.getText().trim().equals("Marca") || marca.getText().trim().equals("")) {
            marca.setText("Marca");
            marca.setForeground(new Color(204, 204, 204));
        }
    }//GEN-LAST:event_marcaFocusLost

    private void modeloKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_modeloKeyPressed
        if (modelo.getText().trim().equals("Modelo")) {
            modelo.setText(null);
            modelo.setForeground(new Color(102, 102, 102));
        }
    }//GEN-LAST:event_modeloKeyPressed

    private void modeloFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_modeloFocusLost
        this.ajuda.setText("Ajuda.");
        if (modelo.getText().trim().equals("Modelo") || modelo.getText().trim().equals("")) {
            modelo.setText("Modelo");
            modelo.setForeground(new Color(204, 204, 204));
        }
    }//GEN-LAST:event_modeloFocusLost

    private void velocidadeFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_velocidadeFocusLost
        this.ajuda.setText("Ajuda.");
        if (velocidade.getText().trim().equals("Velocidade") || velocidade.getText().trim().equals("")) {
            velocidade.setText("Velocidade");
            velocidade.setForeground(new Color(204, 204, 204));
        }
    }//GEN-LAST:event_velocidadeFocusLost

    private void velocidadeKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_velocidadeKeyPressed
        if (velocidade.getText().trim().equals("Velocidade")) {
            velocidade.setText(null);
            velocidade.setForeground(new Color(102, 102, 102));
        }
    }//GEN-LAST:event_velocidadeKeyPressed

    private void tipoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tipoFocusLost
        this.ajuda.setText("Ajuda.");
        if (tipo.getText().trim().equals("Tipo") || tipo.getText().trim().equals("")) {
            tipo.setText("Tipo");
            tipo.setForeground(new Color(204, 204, 204));
        }
    }//GEN-LAST:event_tipoFocusLost

    private void tipoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tipoKeyPressed
        if (tipo.getText().trim().equals("Tipo")) {
            tipo.setText(null);
            tipo.setForeground(new Color(102, 102, 102));
        }
    }//GEN-LAST:event_tipoKeyPressed

    private void resolucaoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_resolucaoFocusLost
        this.ajuda.setText("Ajuda.");
        if (resolucao.getText().trim().equals("Resolução") || resolucao.getText().trim().equals("")) {
            resolucao.setText("Resolução");
            resolucao.setForeground(new Color(204, 204, 204));
        }
    }//GEN-LAST:event_resolucaoFocusLost

    private void resolucaoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_resolucaoKeyPressed
        if (resolucao.getText().trim().equals("Resolução")) {
            resolucao.setText(null);
            resolucao.setForeground(new Color(102, 102, 102));
        }
    }//GEN-LAST:event_resolucaoKeyPressed

    private void cicloFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_cicloFocusLost
        this.ajuda.setText("Ajuda.");
        if (ciclo.getText().trim().equals("Ciclo mensal") || ciclo.getText().trim().equals("")) {
            ciclo.setText("Ciclo mensal");
            ciclo.setForeground(new Color(204, 204, 204));
        }
    }//GEN-LAST:event_cicloFocusLost

    private void cicloKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cicloKeyPressed
        if (ciclo.getText().trim().equals("Ciclo mensal")) {
            ciclo.setText(null);
            ciclo.setForeground(new Color(102, 102, 102));
        }
    }//GEN-LAST:event_cicloKeyPressed

    private void memoriaFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_memoriaFocusLost
        this.ajuda.setText("Ajuda.");
        if (memoria.getText().trim().equals("Memória") || memoria.getText().trim().equals("")) {
            memoria.setText("Memória");
            memoria.setForeground(new Color(204, 204, 204));
        }
    }//GEN-LAST:event_memoriaFocusLost

    private void memoriaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_memoriaKeyPressed
        if (memoria.getText().trim().equals("Memória")) {
            memoria.setText(null);
            memoria.setForeground(new Color(102, 102, 102));
        }
    }//GEN-LAST:event_memoriaKeyPressed

    private void processadorFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_processadorFocusLost
        this.ajuda.setText("Ajuda.");
        if (processador.getText().trim().equals("Processador") || processador.getText().trim().equals("")) {
            processador.setText("Processador");
            processador.setForeground(new Color(204, 204, 204));
        }
    }//GEN-LAST:event_processadorFocusLost

    private void processadorKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_processadorKeyPressed
        if (processador.getText().trim().equals("Processador")) {
            processador.setText(null);
            processador.setForeground(new Color(102, 102, 102));
        }
    }//GEN-LAST:event_processadorKeyPressed

    private void conectividadeFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_conectividadeFocusLost
        this.ajuda.setText("Ajuda.");
    }//GEN-LAST:event_conectividadeFocusLost

    private void conectividadeKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_conectividadeKeyPressed
        if (conectividade.getText().trim().equals("Conectividade")) {
            conectividade.setText(null);
            conectividade.setForeground(new Color(102, 102, 102));
        }
    }//GEN-LAST:event_conectividadeKeyPressed

    private void papelFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_papelFocusLost
        this.ajuda.setText("Ajuda.");
        if (papel.getText().trim().equals("Capacidade de papel") || papel.getText().trim().equals("")) {
            papel.setText("Capacidade de papel");
            papel.setForeground(new Color(204, 204, 204));
        }
    }//GEN-LAST:event_papelFocusLost

    private void papelKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_papelKeyPressed
        if (papel.getText().trim().equals("Capacidade de papel")) {
            papel.setText(null);
            papel.setForeground(new Color(102, 102, 102));
        }
    }//GEN-LAST:event_papelKeyPressed

    private void valorMaximoVendaFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_valorMaximoVendaFocusLost
        this.ajuda.setText("Ajuda.");
        if (valorMaximoVenda.getText().trim().equals("Valor máximo (venda)") || valorMaximoVenda.getText().trim().equals("")) {
            valorMaximoVenda.setText("Valor máximo (venda)");
            valorMaximoVenda.setForeground(new Color(204, 204, 204));
        }
    }//GEN-LAST:event_valorMaximoVendaFocusLost

    private void valorMaximoVendaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_valorMaximoVendaKeyPressed
        if (valorMaximoVenda.getText().trim().equals("Valor máximo (venda)")) {
            valorMaximoVenda.setText(null);
            valorMaximoVenda.setForeground(new Color(102, 102, 102));
        }
    }//GEN-LAST:event_valorMaximoVendaKeyPressed

    private void rendimentoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_rendimentoFocusLost
        this.ajuda.setText("Ajuda.");
        if (rendimento.getText().trim().equals("Rendimento do toner") || rendimento.getText().trim().equals("")) {
            rendimento.setText("Rendimento do toner");
            rendimento.setForeground(new Color(204, 204, 204));
        }
    }//GEN-LAST:event_rendimentoFocusLost

    private void rendimentoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_rendimentoKeyPressed
        if (rendimento.getText().trim().equals("Rendimento do toner")) {
            rendimento.setText(null);
            rendimento.setForeground(new Color(102, 102, 102));
        }
    }//GEN-LAST:event_rendimentoKeyPressed

    private void valorMaximoLocacaoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_valorMaximoLocacaoFocusLost
        this.ajuda.setText("Ajuda.");
        if (valorMaximoLocacao.getText().trim().equals("Valor máximo (locação)r") || valorMaximoLocacao.getText().trim().equals("")) {
            valorMaximoLocacao.setText("Valor máximo (locação)");
            valorMaximoLocacao.setForeground(new Color(204, 204, 204));
        }
    }//GEN-LAST:event_valorMaximoLocacaoFocusLost

    private void valorMaximoLocacaoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_valorMaximoLocacaoKeyPressed
        if (valorMaximoLocacao.getText().trim().equals("Valor máximo (locação)")) {
            valorMaximoLocacao.setText(null);
            valorMaximoLocacao.setForeground(new Color(102, 102, 102));
        }
    }//GEN-LAST:event_valorMaximoLocacaoKeyPressed

    private void valorMinVendaFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_valorMinVendaFocusLost
        this.ajuda.setText("Ajuda.");
        if (valorMinVenda.getText().trim().equals("Valor mínimo (venda)") || valorMinVenda.getText().trim().equals("")) {
            valorMinVenda.setText("Valor mínimo (venda)");
            valorMinVenda.setForeground(new Color(204, 204, 204));
        }
    }//GEN-LAST:event_valorMinVendaFocusLost

    private void valorMinVendaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_valorMinVendaKeyPressed
        if (valorMinVenda.getText().trim().equals("Valor mínimo (venda)")) {
            valorMinVenda.setText(null);
            valorMinVenda.setForeground(new Color(102, 102, 102));
        }
    }//GEN-LAST:event_valorMinVendaKeyPressed

    private void valorMinLocacaoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_valorMinLocacaoFocusLost
        this.ajuda.setText("Ajuda.");
        if (valorMinLocacao.getText().trim().equals("Valor mínimo (locação))") || valorMinLocacao.getText().trim().equals("")) {
            valorMinLocacao.setText("Valor mínimo (locação)");
            valorMinLocacao.setForeground(new Color(204, 204, 204));
        }
    }//GEN-LAST:event_valorMinLocacaoFocusLost

    private void valorMinLocacaoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_valorMinLocacaoKeyPressed
        if (valorMinLocacao.getText().trim().equals("Valor mínimo (locação)")) {
            valorMinLocacao.setText(null);
            valorMinLocacao.setForeground(new Color(102, 102, 102));
        }
    }//GEN-LAST:event_valorMinLocacaoKeyPressed

    private void salvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_salvarActionPerformed
        try {
            FileInputStream url_ref = new FileInputStream(img);
            FachadaProduto fachaProduto = new FachadaProduto();
            fachaProduto.SalvarProduto(marca.getText(), url_ref, modelo.getText(),
                    tipo.getText(), velocidade.getText(), ciclo.getText(), duplex.isSelected(),
                    resolucao.getText(), processador.getText(), memoria.getText(),
                    papel.getText(), conectividade.getText(), fax.isSelected(),
                    digitalizacao.isSelected(), rendimento.getText(), Float.parseFloat(valorMaximoVenda.getText()),
                    Float.parseFloat(valorMinVenda.getText()), Float.parseFloat(valorMaximoLocacao.getText()),
                    Float.parseFloat(valorMinLocacao.getText()));
        } catch (SQLException | ClassNotFoundException | FileNotFoundException ex) {
            JOptionPane.showMessageDialog(rendimento, "Erro: \n" + ex.getMessage());
        }
    }//GEN-LAST:event_salvarActionPerformed

    private void marcaFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_marcaFocusGained
        this.ajuda.setText("* Digite a marca do equipamento no qual deseja adicionar ao repositório.");
    }//GEN-LAST:event_marcaFocusGained

    private void modeloFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_modeloFocusGained
        this.ajuda.setText("* Digite a modelo do equipamento no qual deseja adicionar ao repositório.");
    }//GEN-LAST:event_modeloFocusGained

    private void tipoFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tipoFocusGained
        this.ajuda.setText("* Digite a tipo do equipamento, se é impressora ou impressora multifuncional.");
    }//GEN-LAST:event_tipoFocusGained

    private void velocidadeFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_velocidadeFocusGained
        this.ajuda.setText("* Digite a velocidade do equipamento no qual deseja adicionar ao repositório.");
    }//GEN-LAST:event_velocidadeFocusGained

    private void cicloFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_cicloFocusGained
        this.ajuda.setText("* Digite a quantidade máxima de páginas que podem ser produzidas em um mês.");
    }//GEN-LAST:event_cicloFocusGained

    private void resolucaoFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_resolucaoFocusGained
        this.ajuda.setText("* Digite a resolução máxima do equipamento.");
    }//GEN-LAST:event_resolucaoFocusGained

    private void processadorFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_processadorFocusGained
        this.ajuda.setText("* Digite o modelo e a frequência do processador do equipamento.");
    }//GEN-LAST:event_processadorFocusGained

    private void memoriaFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_memoriaFocusGained
        this.ajuda.setText("* Digite a memória do equipamento no qual deseja adicionar ao repositório.");
    }//GEN-LAST:event_memoriaFocusGained

    private void papelFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_papelFocusGained
        this.ajuda.setText("* Digite a capacidade de papel do equipamento no qual deseja adicionar ao repositório.");
    }//GEN-LAST:event_papelFocusGained

    private void conectividadeFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_conectividadeFocusGained
        this.ajuda.setText("* Digite quais os tipos de conectividade o equipamento possui.");
    }//GEN-LAST:event_conectividadeFocusGained

    private void rendimentoFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_rendimentoFocusGained
        this.ajuda.setText("* Digite a quantidade que o toner deste equipamento rende.");
    }//GEN-LAST:event_rendimentoFocusGained

    private void valorMaximoVendaFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_valorMaximoVendaFocusGained
        this.ajuda.setText("* Digite o valor máximo que esse equipamento possa ser vendido.");
    }//GEN-LAST:event_valorMaximoVendaFocusGained

    private void valorMinVendaFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_valorMinVendaFocusGained
        this.ajuda.setText("* Digite o valor mínimo que esse equipamento possa ser vendido.");
    }//GEN-LAST:event_valorMinVendaFocusGained

    private void valorMaximoLocacaoFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_valorMaximoLocacaoFocusGained
        this.ajuda.setText("* Digite o valor máximo que esse equipamento possa ser locado.");
    }//GEN-LAST:event_valorMaximoLocacaoFocusGained

    private void valorMinLocacaoFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_valorMinLocacaoFocusGained
        this.ajuda.setText("* Digite o valor mínimo que esse equipamento possa ser locado.");
    }//GEN-LAST:event_valorMinLocacaoFocusGained
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel ajuda;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.ButtonGroup buttonGroup3;
    private javax.swing.JButton cancelar;
    private javax.swing.JTextField ciclo;
    private javax.swing.JTextField conectividade;
    private javax.swing.JCheckBox digitalizacao;
    private javax.swing.JCheckBox duplex;
    private javax.swing.JCheckBox fax;
    private javax.swing.JLabel imagen;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JTextField marca;
    private javax.swing.JTextField memoria;
    private javax.swing.JTextField modelo;
    private javax.swing.JTextField papel;
    private javax.swing.JTextField processador;
    private javax.swing.JTextField rendimento;
    private javax.swing.JTextField resolucao;
    private javax.swing.JButton salvar;
    private javax.swing.JPanel status;
    private javax.swing.JTextField tipo;
    private javax.swing.JTextField valorMaximoLocacao;
    private javax.swing.JTextField valorMaximoVenda;
    private javax.swing.JTextField valorMinLocacao;
    private javax.swing.JTextField valorMinVenda;
    private javax.swing.JTextField velocidade;
    // End of variables declaration//GEN-END:variables
}
